package com.defysoft.waukids;

import android.content.Context;
import android.content.SharedPreferences;

public class PublicSharedpreferences {
	Context context;
	Data_Sharedpreferences.SF_Member member_data;
	Data_Sharedpreferences.SF_School school_data;
	Data_Sharedpreferences.SF_Class class_data;
	Data_Sharedpreferences.SF_Student student_data;
	Data_Sharedpreferences.SF_Adnotice adnotice_data;
	private SharedPreferences sp;
	private SharedPreferences.Editor edit;
	
	public PublicSharedpreferences(Context context){
		this.context=context;
	}

	public Data_Sharedpreferences.SF_Member getMembersp() {
		if (member_data == null) {
			return null;
		} else {
			return member_data;
		}
	}
	
	public Data_Sharedpreferences.SF_Adnotice getAdnotice() {
		if (adnotice_data == null) {
			return null;
		} else {
			return adnotice_data;
		}
	}
	
	public Data_Sharedpreferences.SF_School getSchoolsp() {
		if (school_data == null) {
			return null;
		} else {
			return school_data;
		}
	}
	
	public Data_Sharedpreferences.SF_Class getClasssp() {
		if (class_data == null) {
			return null;
		} else {
			return class_data;
		}
	}
	
	public Data_Sharedpreferences.SF_Student getStudentsp() {
		if (student_data == null) {
			return null;
		} else {
			return student_data;
		}
	}
	
	public SharedPreferences.Editor getMember_edit() {
		edit = context.getSharedPreferences("member", context.MODE_PRIVATE)
				.edit();
		return edit;
	}
	
	public SharedPreferences.Editor getSchool_edit() {
		edit = context.getSharedPreferences("school", context.MODE_PRIVATE)
				.edit();
		return edit;
	}
	
	public SharedPreferences.Editor getClass_edit() {
		edit = context.getSharedPreferences("class", context.MODE_PRIVATE)
				.edit();
		return edit;
	}
	
	public SharedPreferences.Editor getStudent_edit() {
		edit = context.getSharedPreferences("student", context.MODE_PRIVATE)
				.edit();
		return edit;
	}

	public SharedPreferences.Editor getAdnotice_edit() {
		edit = context.getSharedPreferences("adnotice", context.MODE_PRIVATE)
				.edit();
		return edit;
	}
	
	public void setAdnotice(){
		adnotice_data = new Data_Sharedpreferences.SF_Adnotice();
	   sp = context.getSharedPreferences("adnotice", context.MODE_PRIVATE);
	   adnotice_data.aDate = sp.getString("Date", "");
	};
	
	public void setMembersp() {
		member_data=new Data_Sharedpreferences.SF_Member();
		sp = context.getSharedPreferences ("member", context.MODE_PRIVATE);
		member_data.Class=sp.getString("Class", "");
		member_data.Connect=sp.getString("Connect", "");
		member_data.CreateDate=sp.getString("CreateDate", "");
		member_data.Email=sp.getString("Email", "");
		member_data.Name=sp.getString("Name", "");
		member_data.Pass=sp.getString("Pass", "");
		member_data.Rank=sp.getString("Rank", "");
		member_data.School=sp.getString("School", "");
		member_data.UUID=sp.getString("UUID", "");
	}

	public void setSchoolsp() {
		school_data = new Data_Sharedpreferences.SF_School();
		sp = context.getSharedPreferences ("school", context.MODE_PRIVATE);
		school_data.Address=sp.getString("Address", "");
		school_data.Address_Code=sp.getString("Address_Code", "");
		school_data.Code=sp.getString("Code", "");
		school_data.Delete=sp.getString("Delete", "");
		school_data.Info=sp.getString("Info", "");
		school_data.Logo=sp.getString("Logo", "");
		school_data.Name=sp.getString("Name", "");
		school_data.Document=sp.getString("Document", "");
		school_data.Cctv=sp.getString("Cctv", "");
		school_data.Cctv_Time_Start=sp.getString("Cctv_Time_Start", "");
		school_data.Cctv_Time_Stop=sp.getString("Cctv_Time_Stop", "");
	}	

	public void setClasssp() {
		class_data = new Data_Sharedpreferences.SF_Class();
		sp = context.getSharedPreferences ("class", context.MODE_PRIVATE);
		class_data.Code=sp.getString("Code", "");
		class_data.Info=sp.getString("Info", "");
		class_data.Name=sp.getString("Name", "");
		class_data.School=sp.getString("School", "");
	}

	public void setStudentsp() {
		student_data= new Data_Sharedpreferences.SF_Student();
		sp = context.getSharedPreferences ("student", context.MODE_PRIVATE);
		student_data.Birth=sp.getString("Birth", "");
		student_data.Class=sp.getString("Class", "");
		student_data.Code=sp.getString("Code", "");
		student_data.Email=sp.getString("Email", "");
		student_data.Info=sp.getString("Info", "");
		student_data.Name=sp.getString("Name", "");
		student_data.Photo=sp.getString("Photo", "");
		student_data.Ran_Stucode=sp.getString("Ran_Stucode", "");
		student_data.School=sp.getString("School", "");
	}
	
	public void delMembersp(){
		edit=context.getSharedPreferences ("member", context.MODE_PRIVATE).edit();
		edit.clear();
		edit.commit();
	}
	
	public void delSchoolsp(){
		edit=context.getSharedPreferences ("school", context.MODE_PRIVATE).edit();
		edit.clear();
		edit.commit();
	}
	
	public void delClasssp(){
		edit=context.getSharedPreferences ("class", context.MODE_PRIVATE).edit();
		edit.clear();
		edit.commit();
	}
	
	public void delStudentsp(){
		edit=context.getSharedPreferences ("student", context.MODE_PRIVATE).edit();
		edit.clear();
		edit.commit();
	}
	
	public class SF_Member_Key {
		public final static String EMAIL = "Email";
		public final static String PASS = "Pass";
		public final static String SCHOOL = "School";
		public final static String CLASS = "Class";
		public final static String NAME = "Name";
		public final static String CREATEDATE = "CreateDate";
		public final static String UUID = "UUID";
		public final static String CONNECT = "Connect";
		public final static String Rank = "Rank";	
	}

	public class SF_School_Key {
		public final static String CODE = "Code";
		public final static String ADDRESS_Code = "Address_Code";
		public final static String NAME = "Name";
		public final static String ADDRESS = "Address";
		public final static String INFO = "Info";
		public final static String DELETE = "Delete";
		public final static String LOGO = "Logo";
		public final static String DOCUMENT = "Document";
		public final static String CCTV = "Cctv";
		public final static String CCTVTIMESTART = "Cctv_Time_Start";
		public final static String CCTVTIMESTOP = "Cctv_Time_Stop";
	}

	public class SF_Class_Key {
		public final static String CODE = "Code";
		public final static String SCHOOL = "School";
		public final static String INFO = "Info";
		public final static String NAME = "Name";
	}

	public class SF_Student_Key {
		public final static String CODE = "Code";
		public final static String SCHOOL = "School";
		public final static String CLASS = "Class";
		public final static String NAME = "Name";
		public final static String BIRTH= "Birth";
		public final static String INFO = "Info";
		public final static String EMAIL = "Email";
		public final static String PHOTO = "Photo";
		public final static String RAN_STUCODE = "Ran_Stucode";
	}
	
	public class SF_Adnotice_Key{
		public final static String DATE = "Date";
	}
	
}
